'''
以第一个字符串为基准不断的 缩减
'''
def longestCommonPrefix(str):
    prefix = str[0]  
    for i in range(1,len(str)):
         while not str[i].startswith(prefix):
             prefix=prefix[:-1]  ## prefix 每次减1
             if not prefix:      ## not prefix 的含义是 如果 prefix 是 False (空的情况下为 false)
                 return ""
    return prefix
    
if __name__ == "__main__":
     print(longestCommonPrefix(["flower","flow","flight"]))     # 输出: "fl"